package com.pc.admin.service.ipml;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pc.admin.entity.LoanRegiStraTion;
import com.pc.admin.mapper.LoanRegiStraTionMapper;
import com.pc.admin.service.LoanRegiStraTionService;
import com.pc.admin.util.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
@Slf4j
public class LoanRegiStraTionServiceImpl implements LoanRegiStraTionService {


    @Autowired
    private LoanRegiStraTionMapper loanRegiStraTionMapper;


    @Override
    public PageResult<LoanRegiStraTion> findPage(Long page, Long pageSize, LoanRegiStraTion loanRegiStraTion) {
        Page<LoanRegiStraTion> tionPage = new Page<>(page, pageSize);
        LambdaQueryWrapper<LoanRegiStraTion> lqw = new LambdaQueryWrapper<>();
            lqw.eq(loanRegiStraTion.getLoanStatus() != null,LoanRegiStraTion::getLoanStatus, loanRegiStraTion.getLoanStatus());
            lqw.eq(loanRegiStraTion.getLoanRegister() != null,LoanRegiStraTion::getLoanRegister, loanRegiStraTion.getLoanRegister());
            lqw.like(StringUtils.isNotBlank(loanRegiStraTion.getOrderCode()),LoanRegiStraTion::getOrderCode, loanRegiStraTion.getOrderCode());
            lqw.like(StringUtils.isNotBlank(loanRegiStraTion.getBorrower()),LoanRegiStraTion::getBorrower, loanRegiStraTion.getBorrower());
            lqw.like(loanRegiStraTion.getBorTel() != null,LoanRegiStraTion::getBorTel, loanRegiStraTion.getBorTel());
        loanRegiStraTionMapper.selectPage(tionPage, lqw);
        log.debug("分页记录数{}，当前页面数据{}", tionPage.getTotal(), tionPage.getRecords());
        return new PageResult<>(tionPage.getTotal(), tionPage.getRecords(), tionPage.getSize(), tionPage.getCurrent());
    }
}
